﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;

namespace Rensselaer_Event_Finder.Hibernate.DAO
{
    public class SyncDAO : GenericNHibernateDAO<Sync, int>
    {
        /// <summary>
        ///  Make the entity persistent. It will be inserted or updated in the database 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        new public Sync save(Sync entity)
        {
            IQuery q = Session.CreateSQLQuery("update syncs set updated_time = now()");
            q.ExecuteUpdate();
            return entity;
        }

        new public Sync getById(int id)
        {
            IQuery q = Session.GetNamedQuery("Sync.byId");
            q.SetInt32("Id", id);
            return q.List<Sync>()[0];
        }

    }
}
